package com.yang.action;

import com.yang.entity.OrderDetail;
import com.yang.service.OrderDetailService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Date;

@WebServlet("/updateOrderDetail")
public class OrderDetailUpdateAction extends HttpServlet {
    OrderDetailService orderDetailService = new OrderDetailService();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        OrderDetail orderDetail = new OrderDetail();
        String id = req.getParameter("id");
        orderDetail.setId(Integer.parseInt(id));
        String productName = req.getParameter("productName");
        orderDetail.setProductName(productName);
        String productPrice = req.getParameter("productPrice");
        String productCount = req.getParameter("productCount");
        orderDetail.setProductCount(Integer.parseInt(productCount));
        String orderId = req.getParameter("orderId");
        orderDetail.setOrderId(orderId);
        String productId = req.getParameter("productId");
        orderDetail.setProductId(Integer.parseInt(productId));
        int num = orderDetailService.updateOrderDetailById(orderDetail);
        resp.setContentType("text/text;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.print(num);
        out.flush();
        out.close();
    }
}

